<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="favicon.ico" >
<link rel="Shortcut Icon" href="favicon.ico" />
<link rel="stylesheet" type="text/css" href="{{ URL::asset('/admin/h-ui/css/H-ui.min.css') }}"/>
<link rel="stylesheet" type="text/css" href="{{ URL::asset('/admin/h-ui.admin/css/H-ui.admin.css') }}" />
<link rel="stylesheet" type="text/css" href="{{ URL::asset('/admin/lib/Hui-iconfont/1.0.8/iconfont.css') }}"  />
<link rel="stylesheet" type="text/css" href="{{ URL::asset('/admin/h-ui.admin/skin/default/skin.css') }}"  id="skin" />
<link rel="stylesheet" type="text/css" href="{{ URL::asset('/admin/h-ui.admin/css/style.css') }}" />

</head>
<body>
<article class="cl pd-20">
	<form action="/admin/role/editGroup" method="post" class="form form-horizontal" id="form-admin-group-edit">
		{{ csrf_field() }}
		<input type="hidden" name="id" value="{{ $group_data['id'] }}">
		<div class="row cl">
			<label class="form-label col-xs-2 col-sm-2"><span class="c-red">*</span>角色名称：</label>
			<div class="formControls col-xs-10 col-sm-10">
				<input type="text" class="input-text" value="{{ $group_data['title'] }}" id="title" name="title">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-2 col-sm-2"><span class="c-red">*</span>角色描述：</label>
			<div class="formControls col-xs-10 col-sm-10">
				<input type="text" class="input-text" value="{{ $group_data['msg'] }}" id="msg" name="msg">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-2 col-sm-2"><span class="c-red">*</span>权限：</label>
			<div class="formControls col-xs-10 col-sm-10">
				
				@foreach ($rule_data as $k)
				<dl class="permission-list">	
					<dt class="">
						<label>
							<input type="checkbox" value="{{ $k['id'] }}" name="rule_ids[]" id="user-Character-0" @if(in_array($k['id'], $group_data['rules'])) checked="checked" @endif>
							{{ $k['title'] }}
						</label>
					</dt>
					@foreach ($k['_data'] as $key)
					<dd >
						<dl class="cl permission-list2">
							<dt>
								<label class="">
									<input type="checkbox" value="{{ $key['id'] }}" name="rule_ids[]" id="user-Character-0-0" @if(in_array($key['id'], $group_data['rules'])) checked="checked" @endif>
									{{ $key['title'] }}
								</label>
							</dt>
							<dd>
								@if ( !empty($key['_data']) )
									@foreach ($key['_data'] as $kk)
									<label class="">
										<input type="checkbox" value="{{ $kk['id'] }}" name="rule_ids[]" id="user-Character-0-0-0" @if(in_array($kk['id'], $group_data['rules'])) checked="checked" @endif>
										{{ $kk['title'] }}
									</label>
									@endforeach
								@endif
							</dd>
						</dl>
					</dd>
					@endforeach
				</dl>	
				@endforeach
				
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<button type="submit" class="btn btn-success radius"><i class="icon-ok"></i>修改</button>
			</div>
		</div>
	</form>
</article>


<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="{{ URL::asset('/admin/lib/jquery/1.9.1/jquery.min.js') }}"></script> 
<script type="text/javascript" src="{{ URL::asset('/admin/lib/layer/2.4/layer.js') }}"></script>
<script type="text/javascript" src="{{ URL::asset('/admin/h-ui/js/H-ui.js') }}"></script> 
<script type="text/javascript" src="{{ URL::asset('/admin/h-ui.admin/js/H-ui.admin.page.js') }}"></script> 
<!--/_footer /作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="{{ URL::asset('/admin/lib/jquery.validation/1.14.0/jquery.validate.js') }}"></script> 
<script type="text/javascript" src="{{ URL::asset('/admin/lib/jquery.validation/1.14.0/validate-methods.js') }}"></script> 
<script type="text/javascript" src="{{ URL::asset('/admin/lib/jquery.validation/1.14.0/messages_zh.js') }}"></script> 
<script type="text/javascript">
$(function(){
	
	$(".permission-list dt input:checkbox").click(function(){
		$(this).closest("dl").find("dd input:checkbox").prop("checked",$(this).prop("checked"));
	});
	$(".permission-list2 dd input:checkbox").click(function(){
		var l =$(this).parent().parent().find("input:checked").length;
		var l2=$(this).parents(".permission-list").find(".permission-list2 dd").find("input:checked").length;
		if($(this).prop("checked")){
			$(this).closest("dl").find("dt input:checkbox").prop("checked",true);
			$(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked",true);
		}else{
			if(l==0){
				$(this).closest("dl").find("dt input:checkbox").prop("checked",false);
			}
			if(l2==0){
				$(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked",false);
			}
		}
	});
	$("#form-admin-group-edit").validate({
		rules:{
			title:{
				required:true,
			},
			msg:{
				required:true,
			}
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			$(form).ajaxSubmit(function(call){
				// console.log(call);return;
				if (call == 1) {
					layer.msg('修改成功!',{icon:1,time:1000},function(){
						//加载刷新父类页面并关闭弹窗
						window.parent.location.reload();
						var index = parent.layer.getFrameIndex(window.name);
						parent.layer.close(index);
					});
				} else {
					layer.msg('修改失败!',{icon:2,time:1000},function(){
						var index = parent.layer.getFrameIndex(window.name);
						parent.layer.close(index);
					});
				}
			});
		}
	});
});
</script>
</body>
</html>